package cn.weekendpi.util;

import java.io.File;
import java.util.List;

/**
 * @author zhangjw
 * @date 2019/12/18
 */
public class IOUtils {

    /**
     * Find all the Java files in the specified directory.
     *
     * @param directory the specified directory.
     * @param javaFiles all the Java files in the specified directory.
     */
    public static void listJavaFiles(File directory, List<File> javaFiles) {
        File[] files = directory.listFiles();
        if (files != null && files.length > 0) {
            for (File file : files) {
                if (file.isDirectory()) {
                    listJavaFiles(file, javaFiles);
                } else if (file.getName().endsWith(".java")) {
                    javaFiles.add(file);
                }
            }
        }
    }
}
